<template>
  <d2-container class="brushhandaudit">
    <template slot="header">升级师傅审核</template>
    <el-row :gutter="20">
      <el-col :span="6" style="display:flex;align-items: center;margin-bottom:10px;">
        <span style="width:200px;">支付宝订单号：</span>
        <el-input size="small" v-model="iptval" placeholder="请输入内容"></el-input>
      </el-col>
      <el-col :span="2">
        <el-button size="mini" type="primary" @click="onSearch">查询</el-button>
      </el-col>
    </el-row>
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column
        label="序号"
        type="index"
        width="200">
      </el-table-column>
      <el-table-column
        width=""
        label="真实姓名"
        prop="user_name">
      </el-table-column>
      <el-table-column
        width=""
        label="支付宝订单号"
        prop="zfb_order">
      </el-table-column>
      <el-table-column
        width=""
        label="充值金额"
        prop="bond_money">
      </el-table-column>
      <el-table-column
        label="提交时间"
        prop="create_time">
      </el-table-column>
      <el-table-column
        fixed="right"
        label="操作"
        width="150">
        <template slot-scope="scope">
          <el-button @click="onSure(scope.row)" type="primary" size="mini" plain>通过</el-button>
          <!--          -->
          <el-button @click="Dialog = true;refuse_row = scope.row" type="danger" size="mini" plain>拒绝</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @current-change="handleCurrentChange"
      :current-page.sync="page"
      :page-size="20"
      layout="total, prev, pager, next"
      :total="total"
      style="text-align:right;margin:10px 0;">
    </el-pagination>
    <el-dialog
      :title="title"
      :visible.sync="cardImgDialog"
      width="30%"
      center>
      <el-image :src="cardimg">
        <div slot="placeholder" class="image-slot">
          加载中<span class="dot">...</span>
        </div>
      </el-image>
    </el-dialog>
    <!--    拒绝-->
    <el-dialog
      title="拒绝理由"
      :visible.sync="Dialog"
      width="30%"
      center>
      <div style="display:flex;">
        <el-input type="text" placeholder="请输入拒绝理由" v-model="refuseing"></el-input>
      </div>
      <br/>
      <el-button type="primary" @click="onRefused()">确认</el-button>
      <el-button type="primary" @click="Dialog = false">取消</el-button>
    </el-dialog>
    <el-dialog
      title="师傅信息"
      :visible.sync="Dialoging"
      width="30%"
      center>
      <div style="display:flex;flex-direction: column;">
        <span style="font-size:18px;">师傅ID:{{teacheruser.id}}</span>
        <br/>
        <span style="font-size:18px;">师傅姓名:{{teacheruser.t_name}}</span>
      </div>
    </el-dialog>
    <remote-js src="http://pv.sohu.com/cityjson?ie=utf-8"></remote-js>
  </d2-container>
</template>

<script>
  import { examineBond,refuseBond,BondList} from "@/api/sys.login";
  export default {
    data(){
      return{
        tableData:[],
        page:1,
        Dialoging:false,
        total:0,
        ip:'',
        refuseing:"",
        Dialog:false,
        activval:'',
        roleTeacher: [
          {
            value: "1",
            label: "徒弟"
          },
          {
            value: "2",
            label: "师傅"
          },
        ],

        sexTeacher: [
          {
            value: "0",
            label: "未知"
          },
          {
            value: "1",
            label: "男"
          },
          {
            value: "2",
            label: "女"
          },
        ],
        statusTeacher:[
          {
            value: "1",
            label: "用户待审核"
          },
          {
            value: "2",
            label: "用户正常"
          },
          {
            value: "3",
            label: "用户冻结"
          },
          {
            value: "4",
            label: "用户审核中"
          },
        ],
        activlist:[
          {
            value: 1,
            label:'待审核',
          },
          {
            value: 2,
            label:'正常',
          },
          {
            value: 3,
            label:'冻结',
          },
          {
            value: 4,
            label:'审核中',
          }
        ],
        teacheruser:"",
        auditval:'',
        auditlist:[
          {
            value:'微信名称',
            label:'微信名称',
          },
          {
            value:'真实姓名',
            label:'真实姓名',
          },
          {
            value:'手机号码',
            label:'手机号码',
          },
          {
            value:'分组',
            label:'分组',
          },
          {
            value:'旺旺号',
            label:'旺旺号',
          },
          {
            value:'角色',
            label:'角色',
          },
          {
            value:'师傅微信',
            label:'师傅微信',
          }
        ],
        refuse_row:[],
        iptval:'',
        cardImgDialog:false,
        cardimg:'',
        title:'身份证照片'
      }
    },
    components:{
      'remote-js': {
        render(createElement) {
          return createElement('script', { attrs: { type: 'text/javascript', src: this.src }});
        },
        props: {
          src: { type: String, required: true },
        },
      },
    },
    mounted(){
      let params = {
        page:this.page,
        pageSize:20
      }
      this.getUserList(params)
    },
    methods:{
      Infochange(row) {
        console.log(row.user_status);
        if(row.role ==  '师傅'){
          row.role = 2
        }else if(row.role == '徒弟'){
          row.role = 1
        }else{
          row.role = 0
        }
        if(row.user_status == "用户待审核"){
          row.user_status =1
        }else if(row.user_status == "用户正常"){
          row.user_status =2
        }else if(row.user_status == "用户冻结"){
          row.user_status =3
        }else if(row.user_status == "用户审核中"){
          row.user_status =4
        }
        console.log(row.sex);
        if(row.sex == '男'){
          row.sex = 1
        }else if(row.sex == '女'){
          row.sex = 2
        }else if(row.sex == '未知'){
          row.sex = 0
        }
        changeInfo(row.taobao_name, row.t_name, row.group, row.role, row.invitation, row.teacher, row.id,row.sex,row.user_status).then((res) => {
          console.log(res.data);let params = {
            page:this.page,
            pageSize:20
          }
          this.getUserList(params)
        })
      },
      MasterLook(teacher) {
        this.Dialoging = true
        teacher_user(teacher)
          .then((res) => {
            this.teacheruser = res.data
          })
      },
      handleCurrentChange(val) {
        this.page = val
        this.onSearch()
      },
      // 获取列表数据
      getUserList(params){
        BondList(params)
          .then((res) => {
            console.log(res);
            this.tableData = res.data
            this.total = res.count
          })
          .catch(() =>{
            this.tableData = []
            this.total = 0
          })
      },
      //查询
      onSearch(){},
      // 通过
      onSure(row){
        examineBond({
          ip:returnCitySN["cip"],
          bond_id:row.id
        })
          .then((res) => {
            console.log('通过',res)
            let params = {
              page:this.page,
              pageSize:20
            }
            this.getUserList(params)
          })
      },
      // 拒绝
      onRefused(){
        refuseBond({
          remarks:this.refuseing,
          ip:returnCitySN["cip"],
          bond_id:this.refuse_row.id
        })
          .then((res) => {
            console.log('拒绝',res)
            let params = {
              page:this.page,
              pageSize:20
            }
            this.getUserList(params)
            this.Dialog = false
          })
      },
    }
  }
</script>

<style lang="scss" scoped>

</style>
<style lang="scss">
  .brushhandaudit{
    .demo-table-expand {
      font-size: 0;
    }
    .demo-table-expand label {
      width: 90px;
      color: #99a9bf;
    }
    .demo-table-expand .el-form-item {
      margin-right: 0;
      margin-bottom: 0;
      width: 50%;
    }
  }
</style>
